//
//  NYMember.m
//  NOAHWM
//
//  Created by Ryan on 13-5-14.
//  Copyright (c) 2013年 Ryan. All rights reserved.
//

#import "NYMember.h"


#define kAccountIdKey                   @"AccountIdKey"
#define kAccountNameKey                 @"AccountNameKey"
#define kMemberCardTypeKey              @"MemberCardTypeKey"
#define kRecordTypeNameKey              @"RecordTypeNameKey"
#define kUserNameKey                    @"UserNameKey"
#define kPhoneNumKey                    @"PhoneNumKey"
#define kDynPwdKey                      @"DynPwdKey"
#define kStatusKey                      @"StatusKey"
#define kIs_gesture_passwordKey         @"Is_gesture_passwordKey"
#define kGesture_passwordKey            @"Gesture_passwordKey"
#define kIs_authKey                     @"Is_authKey"
#define kLoginLogIdKey                  @"LoginLogIdKey"
#define kAddressKey                     @"AddressKey"
#define kComper_pointKey                @"Comper_pointKey"
#define kCustom_service_phoneKey        @"Custom_service_phoneKey"
#define kFp_mobileKey                   @"Fp_mobileKey"
#define kFp_nameKey                     @"Fp_nameKey"
#define kRoleIdKey                      @"RoleIdKey"
#define kUserIconKey                    @"UserIconKey"
#define kMemberTypeKey                  @"MemberTypeKey"
#define kRemind_countKey                @"Remind_countKey"

@implementation NYMember

@synthesize accountId,accountName,memberCardType,recordTypeName,userName,phoneNum,dynPwd;
@synthesize status,loginLogId;
@synthesize address;
@synthesize comper_point,fp_mobile,fp_name;
@synthesize memberType;
@synthesize is_gesture_password,is_auth,gesture_password;
@synthesize userIcon;
@synthesize roleId;
@synthesize custom_service_phone;
@synthesize remind_count;

- (id)init
{
    if(self = [super init])
    {
        self.custom_service_phone = kDefaultPhoneNum;
    }
    return self;
}

- (void)dealloc
{
    [custom_service_phone release];
    [roleId release];
    [userIcon release];
    [gesture_password release];
    [is_gesture_password release];
    [is_auth release];
    
    [comper_point release];
    [fp_mobile release];
    [fp_name release];
    
    [status release];
    [loginLogId release];
    [dynPwd release];
    [accountId release];
    [userName release];
    [phoneNum release];
    [accountName release];
    [memberCardType release];
    [recordTypeName release];
    [address release];
    [remind_count release];
    [super dealloc];
}

- (MemberType)memberType
{
    if([self.roleId isEqualToString:@"002"])
        return kMemberRegister;
    else if([self.roleId isEqualToString:@"003"])
        return kMemberAuthentication;
    else
        return kMemberVisitor;
}

- (BOOL)gestureOpen
{
    if(nil == self.accountId || [self.accountId isEqualToString:@""])
        return NO;
    if([self.is_gesture_password isEqualToString:@"1"])
        return YES;
    else
        return NO;
}

#pragma mark - NSCoding methods
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.accountId forKey:kAccountIdKey];
    [aCoder encodeObject:self.accountName forKey:kAccountNameKey];
    [aCoder encodeObject:self.memberCardType forKey:kMemberCardTypeKey];
    [aCoder encodeObject:self.recordTypeName forKey:kRecordTypeNameKey];
    [aCoder encodeObject:self.userName forKey:kUserNameKey];
    [aCoder encodeObject:self.phoneNum forKey:kPhoneNumKey];
    [aCoder encodeObject:self.dynPwd forKey:kDynPwdKey];
    [aCoder encodeObject:self.status forKey:kStatusKey];
    [aCoder encodeObject:self.is_gesture_password forKey:kIs_gesture_passwordKey];
    [aCoder encodeObject:self.gesture_password forKey:kGesture_passwordKey];
    [aCoder encodeObject:self.is_auth forKey:kIs_authKey];
    [aCoder encodeObject:self.loginLogId forKey:kLoginLogIdKey];
    [aCoder encodeObject:self.address forKey:kAddressKey];
    [aCoder encodeObject:self.comper_point forKey:kComper_pointKey];
    [aCoder encodeObject:self.custom_service_phone forKey:kCustom_service_phoneKey];
    [aCoder encodeObject:self.fp_mobile forKey:kFp_mobileKey];
    [aCoder encodeObject:self.fp_name forKey:kFp_nameKey];
    [aCoder encodeObject:self.roleId forKey:kRoleIdKey];
    [aCoder encodeObject:self.userIcon forKey:kUserIconKey];
    [aCoder encodeInteger:self.memberType forKey:kMemberTypeKey];
    [aCoder encodeObject:self.remind_count forKey:kRemind_countKey];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
    if(self = [super init])
    {
        self.accountId = [aDecoder decodeObjectForKey:kAccountIdKey];
        self.accountName = [aDecoder decodeObjectForKey:kAccountNameKey];
        self.memberCardType = [aDecoder decodeObjectForKey:kMemberCardTypeKey];
        
        self.recordTypeName = [aDecoder decodeObjectForKey:kRecordTypeNameKey];
        self.userName = [aDecoder decodeObjectForKey:kUserNameKey];
        
        self.phoneNum = [aDecoder decodeObjectForKey:kPhoneNumKey];
        self.dynPwd = [aDecoder decodeObjectForKey:kDynPwdKey];
        self.status = [aDecoder decodeObjectForKey:kStatusKey];
        
        self.is_gesture_password = [aDecoder decodeObjectForKey:kIs_gesture_passwordKey];
        self.gesture_password = [aDecoder decodeObjectForKey:kGesture_passwordKey];
        self.is_auth = [aDecoder decodeObjectForKey:kIs_authKey];
        self.loginLogId = [aDecoder decodeObjectForKey:kLoginLogIdKey];
        self.address = [aDecoder decodeObjectForKey:kAddressKey];
        
        self.comper_point = [aDecoder decodeObjectForKey:kComper_pointKey];
        self.custom_service_phone = [aDecoder decodeObjectForKey:kCustom_service_phoneKey];
        
        self.fp_mobile = [aDecoder decodeObjectForKey:kFp_mobileKey];
        self.fp_name = [aDecoder decodeObjectForKey:kFp_nameKey];
        self.roleId = [aDecoder decodeObjectForKey:kRoleIdKey];
        self.userIcon = [aDecoder decodeObjectForKey:kUserIconKey];
        self.memberType = [aDecoder decodeIntegerForKey:kMemberTypeKey];
        self.remind_count = [aDecoder decodeObjectForKey:kRemind_countKey];
    }
    return self;
}

@end
